package com.smart.fifteen.annotate.cacheput;

import com.smart.fifteen.annotate.model.User;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
 * service
 *
 * @author junrui.wang
 * @create 2019/12/19
 */
@Service("userServiceCachePut")
public class UserService {
    @CachePut(cacheNames="users")
    public User getUser(String id){
        System.out.println("find user");
        return getDBUser(id);
    }

    public User getDBUser(String id){
        System.out.println("find user from DB");
        return new User("1", "name", 20);
    }
}
